<template>
  <div class="playList">
    <div class="title-img">
      <van-image height="300" :src="img" fit="cover" />
      <van-icon name="arrow-left" @click="goBack" />
    </div>
    <div class="list">
      <ul class="content">
        <li v-for="item in playlistData" :key="item.songid" class="item">
          <div class="songname">{{ item.songname }}</div>
          <div class="singInfo">
            {{ item.albumname }} -- {{ item.singer[0].name }}
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      value: "",
      playlistData: [],
      img: "",
    };
  },
  created() {
    console.log(this.$route.params.id + " id");
    this.getPlayList();
  },
  methods: {
    getPlayList() {
      axios
        .get("/api/songlist", {
          params: {
            id: this.$route.params.id,
          },
        })
        .then((res) => {
          console.log(res.data);
          this.playlistData = res.data.data.songlist;
          this.img = res.data.data.logo;
        })
        .catch((err) => {
          console.error(err);
        });
    },

    goBack() {
      window.history.length > 1 ? this.$router.go(-1) : this.$router.push("/");
    },
  },
};
</script>

<style scoped>
/* .title-img img {
  width: 100%;
  height: 300px;
} */
.title-img {
  position: relative;
}
.title-img .van-icon {
  color: azure;
  font-size: 30px;
  position: absolute;
  top: 5px;
  left: 0px;
}
.van-image {
  width: 100%;
}
.content {
  width: 100%;
  text-align: left;
}
.content > .item {
  background-color: azure;
  margin-top: 10px;
}
.content > .item > .songname {
  margin-top: 5px;
  font-size: larger;
  font-weight: bold;
}
.content > .item > .singInfo {
  margin: 5px;
}
</style>